<template>
	<view>
		<bg-video></bg-video>
		<cu-custom bgColor="bg-gradual-blue" :isBack="true"><block slot="backText"></block>
			<block slot="content">远程开门</block>
		</cu-custom>
			<view class="cu-form-group margin-top">
				<view class="title text-orange">
					<text class="cuIcon-keyboard"></text>
					<text class="margin-left">密码</text>
				</view>
				<input placeholder="请输入密码" v-model="password" name="input"></input>
			</view>
			<view v-for="(access,index) in accesses" :key="index"
				class="flex flex-direction padding margin bg-white">
				<text class="flex align-start">
					门禁id：{{access.uid}}
				</text>
				<view class="padding flex  flex-direction">
					<button @tap="openDoor(access.accessId)" class="cu-btn bg-blue lg">开门</button>
				</view>
			</view>
			
		</view>
	</view>
</template>

<script>
	export default {
		data: function() {
			return {
				accesses: [],
				password: "",
				storeId: "",
				}
		},
		
		onLoad:function(){
			this.getAccesses();
		},
		onShow:function(){
			this.getAccesses();
		},
		methods: {
			openDoor: function (accessId){
				let self = this;
				this.http.post({
						url: "/client/access/cmd",
						param: {
							password:self.password,
							accessId:accessId,
							CmdCode:1,
							storeId:self.storeId
						}
					}).then(function(res) {
						self.message.info("命令已发送");
					});
				
			},
			getAccesses: function() {
				let self = this;
				this.storeId = this.common.getState().autor.store_client.storeId;
				this.http.get({
						url: "/client/access/access",
						param: {
							storeId:self.storeId
						}
					}).then(function(res) {
						self.accesses = res;
					});
			}
		}
	}
</script>

<style>
</style>
